import {
	ref
} from 'vue'

import {
	defineStore
} from 'pinia'
export const useUserStore = defineStore('user', () => {
	// 1. 定义管理用户数据的state
	const userInfo = ref({
		name: '173******74',
		phone: '17304848274',
		type: 0
	})
	const token = ref('')
	const refresh_token = ref('')
	// 2. 定义获取接口数据的action函数
	const getUserInfo = async (user) => {
		const res = await loginAPI(user)
		userInfo.value = res.result
	}
	// 3. 以对象的格式把state和action return
	return {
		userInfo,
		getUserInfo,refresh_token,
		token
	}
}, {
	persist: true
})